﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace UFIDA.U9.Cust.XH.PlugBE.Model
{
    /// <summary>
    /// 采购订单外协
    /// </summary>
    public class PurchaseOrderWXModel
    {
        public PurchaseOrderWXModel(UFIDA.U9.PM.PO.PurchaseOrder m)
        {
            this.DocType_Name = m.DocType?.Name;
            this.DocNo = m.DocNo;
            this.ExternalContractNo = m.DocNo;
            this.Supplier_Code = m.Supplier?.Code;
            this.BusinessDate = m.BusinessDate;
            this.Status = UFIDA.U9.PM.PO.PODOCStatusEnum.EnumRes.GetResource(m.Status.Name);
            this.ConfirmTerm_Name = m.ConfirmTerm.Name;
            this.PurOper_Name = m.PurOper?.Name;
            this.AccountOrg_Name = m.AccountOrg?.Name;
            this.SettleOrg_Name = m.SettleOrg?.Name;
            this.CreatedBy = m.CreatedBy;
            this.CreatedOn = m.CreatedOn;
            

            foreach (PM.PO.POMemo item in m.POMemos)
            {
                this.Memo += item.Values;
            }
            this.Currency_Name = m.AC.Name;
            foreach (PM.PO.POLine item in m.POLines)
            {
                this.RcvOrg_Name = item.RcvOrg?.Name;
                break;
            }


        }
        public string DocType_Name { get; set; }
        public string DocNo { get; set; }
        public string ExternalContractNo { get; set; }
        public DateTime BusinessDate { get; set; }
        public string Supplier_Code { get; set; }
        public string Status { get; set; }
        public string ConfirmTerm_Name { get; set; }
        public string CreatedBy { get; set; }
        public DateTime CreatedOn { get; set; }
        public string PurOper_Name { get; set; }
        /// <summary>
        /// 核算组织
        /// </summary>
        public string AccountOrg_Name { get; set; }
        /// <summary>
        /// SettleOrg_Name
        /// </summary>
        public string SettleOrg_Name { get; set; }
        /// <summary>
        /// 收货组织
        /// </summary>
        public string RcvOrg_Name { get; set; }
        public string Memo { get; set; }
        public string Currency_Name { get; set; }


    }

    public class PurchaseOrderWXLineModel
    {
        public PurchaseOrderWXLineModel(UFIDA.U9.PM.PO.POLine m)
        {
            this.ItemCode = m.ItemInfo.ItemCode;
            this.ItemName = m.ItemInfo.ItemName;
            this.ItemSPECS = m.ItemInfo.ItemID.SPECS;
            this.ReqQtyTU = m.ReqQtyTU;
            this.PurQtyTU = m.PurQtyTU;
            this.TradeUOM_Name = m.TradeUOM.Name;
            this.Project_Code = m.Project.Code;
            this.Project_Name = m.Project.Name;
            this.TaxRate = m.TaxRate;
            this.TotalTaxAC = m.TotalTaxAC;
            this.TotalMnyAC = m.TotalMnyAC;
            this.FinallyPriceTC = m.FinallyPriceTC;
            this.NetFinallyPriceTC = m.NetFinallyPriceTC;          
            foreach (UFIDA.U9.PM.PO.POShipLine item in m.POShiplines)
            {
                this.CommitDate = item.PlanArriveDate;
                break;
            }
            foreach (UFIDA.U9.CBO.SCM.PickList.SCMPickList item in m.SCMPickHead.SCMPickListS)
            {
                this.PickItemCode = item.ItemInfo.ItemCode;
                this.PickItemName = item.ItemInfo.ItemName;
                this.PickItemSPECS = item.ItemInfo.ItemID.SPECS;
                this.PickActualReqQty = item.ActualReqQty;
                this.PickIssueUOM_Name = item.IssueUOM.Name;
            }
        }
        public string ItemCode { get; set; }
        public string ItemName { get; set; }
        public string ItemSPECS { get; set; }

        public decimal ReqQtyTU { get; set; }
        public decimal PurQtyTU { get; set; }
        public string TradeUOM_Name { get; set; }
        public string Project_Code { get; set; }
        public string Project_Name { get; set; }
        public decimal TaxRate { get; set; }
        public decimal TotalTaxAC { get; set; }
        public decimal TotalMnyAC { get; set; }
        public decimal FinallyPriceTC { get; set; }
        public decimal NetFinallyPriceTC { get; set; }
        public DateTime CommitDate { get; set; }

        public string PickItemCode { get; set; }
        public string PickItemName { get; set; }
        public string PickItemSPECS { get; set; }
        public string PickIssueUOM_Name { get; set; }

        public decimal PickActualReqQty { get; set; }
    }

}
